package com.lifq.flink.streaming

import com.lifq.flink.source.DataGenerator
import org.apache.flink.api.java.utils.ParameterTool
import org.apache.flink.streaming.api.scala.{StreamExecutionEnvironment, _}

/**
 * @Author: LiFuqiang
 * @Date: 2022/9/16 15:14
 * @Version 1.0 
 * @description
 */
object CountWindowExample {
  def main(args: Array[String]): Unit = {


    // Checking input parameters
    //val paramsCC = ParameterTool.fromArgs(args)

    //val customParams = ParameterTool.fromPropertiesFile(paramsCC.get("configpath"))

    // set up the Scala DataStream API
    val env = StreamExecutionEnvironment.getExecutionEnvironment

    val source = env.addSource(new DataGenerator())

    source.map(x => ("oil", x.toInt))
      .keyBy(_._1)
      .countWindow(10, 1)
      .aggregate(new CustomAggFunction(5))
      .print()



    env.execute("CountWindow Test")
  }
}
